home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-02-27 | 2.3 KB | 83 lines | [TEXT/CWIE] |
- /* SK8 © 1997 Apple Computer, Inc.
- This code is protected under the current SK8 License
- See http://sk8.research.apple.com/ for more information
- Apple Research Laboratories
- */
-
-
- import java.awt.*;
-
- class bevelrenderer extends renderer {
-
- //Properties and their setters and getters
- private rgbcolor leftrendererVar = sk8.graytone40;
- private rgbcolor toprendererVar = sk8.graytone20;
- private rgbcolor rightrendererVar = sk8.graytone70;
- private rgbcolor bottomrendererVar = sk8.graytone90;
- private int width = 5;
-
- public rgbcolor leftrenderer() { return leftrendererVar;}
- public void setleftrenderer(rgbcolor val) {
- leftrendererVar = val;
- }
- public rgbcolor toprenderer() { return toprendererVar;}
- public void settoprenderer(rgbcolor val) {
- toprendererVar = val;
- }
- public rgbcolor rightrenderer() { return rightrendererVar;}
- public void setrightrenderer(rgbcolor val) {
- rightrendererVar = val;
- }
- public rgbcolor bottomrenderer() { return bottomrendererVar;}
- public void setbottomrenderer(rgbcolor val) {
- bottomrendererVar = val;
- }
-
- //Constructors
- public bevelrenderer() {
-
- }
- public bevelrenderer(rgbcolor leftrenderer, rgbcolor toprenderer,
- rgbcolor rightrenderer, rgbcolor bottomrenderer) {
- this.setleftrenderer(leftrenderer);
- this.settoprenderer(toprenderer);
- this.setrightrenderer(rightrenderer);
- this.setbottomrenderer(bottomrenderer);
- }
-
- void render(Graphics g, actor act, Region reg) {
- Color currentColor;
- Rectangle drawrect = reg.getBBox();
-
- //calculate the boundsrect points
- int l = drawrect.x;
- int t = drawrect.y;
- int r = l + drawrect.width;
- int b = t + drawrect.height;
- //determine the size of the bevel piece
- int count = (width < drawrect.width / 2) ? width : drawrect.width/2;
- count = (count < drawrect.height /2) ? count : drawrect.height/2;
-
-
- // first, draw the sides as rectangles
- g.setColor(leftrendererVar.currentColor);
- g.fillRect(l, t, count, drawrect.height);
-
- g.setColor(rightrendererVar.currentColor);
- g.fillRect(r - count, t, r, drawrect.height);
-
-
- //then draw the top and the bottom diagonally going inward
- for (; count > 0; count--){
-
- g.setColor(toprendererVar.currentColor);
- g.drawLine (l, t, r, t);
-
- g.setColor(bottomrendererVar.currentColor);
- g.drawLine (l, b, r, b);
-
- l++; r--;
- t++; b--;
- }
- }
- }